<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Owen's T function</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../index.html" title="Math Toolkit 4.2.1">
<link rel="up" href="../special.html" title="Chapter 8. Special Functions">
<link rel="prev" href="inv_hyper/atanh.html" title="atanh">
<link rel="next" href="daubechies.html" title="Daubechies Wavelets and Scaling Functions">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="inv_hyper/atanh.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../special.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="daubechies.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.owens_t"></a><a class="link" href="owens_t.html" title="Owen's T function">Owen's T function</a>
</h2></div></div></div>
<h5>
<a name="math_toolkit.owens_t.h0"></a>
      <span class="phrase"><a name="math_toolkit.owens_t.synopsis"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.synopsis">Synopsis</a>
    </h5>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">math</span><span class="special">/</span><span class="identifier">special_functions</span><span class="special">/</span><span class="identifier">owens_t</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">{</span> <span class="keyword">namespace</span> <span class="identifier">math</span><span class="special">{</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">&gt;</span>
<a class="link" href="result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">owens_t</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">h</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">a</span><span class="special">);</span>

<span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&gt;</span>
<a class="link" href="result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>calculated-result-type</em></span></a> <span class="identifier">owens_t</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">h</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">a</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">&amp;);</span>

<span class="special">}}</span> <span class="comment">// namespaces</span>
</pre>
<h5>
<a name="math_toolkit.owens_t.h1"></a>
      <span class="phrase"><a name="math_toolkit.owens_t.description"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.description">Description</a>
    </h5>
<p>
      Returns the <a href="http://en.wikipedia.org/wiki/Owen%27s_T_function" target="_top">Owens_t
      function</a> of <span class="emphasis"><em>h</em></span> and <span class="emphasis"><em>a</em></span>.
    </p>
<p>
      The final <a class="link" href="../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">Policy</a> argument is optional and can
      be used to control the behaviour of the function: how it handles errors, what
      level of precision to use etc. Refer to the <a class="link" href="../policy.html" title="Chapter 22. Policies: Controlling Precision, Error Handling etc">policy documentation
      for more details</a>.
    </p>
<p>
         
    </p>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="inlinemediaobject"><img src="../../equations/owens_t.svg"></span>

      </p></blockquote></div>
<p>
      <span class="inlinemediaobject"><img src="../../graphs/plot_owens_t.png"></span>
    </p>
<p>
      The function <code class="computeroutput"><span class="identifier">owens_t</span><span class="special">(</span><span class="identifier">h</span><span class="special">,</span> <span class="identifier">a</span><span class="special">)</span></code> gives the probability of the event <span class="emphasis"><em>(X
      &gt; h and 0 &lt; Y &lt; a * X)</em></span>, where <span class="emphasis"><em>X</em></span> and
      <span class="emphasis"><em>Y</em></span> are independent standard normal random variables.
    </p>
<p>
      For h and a &gt; 0, T(h,a), gives the volume of an uncorrelated bivariate normal
      distribution with zero means and unit variances over the area between <span class="emphasis"><em>y
      = ax</em></span> and <span class="emphasis"><em>y = 0</em></span> and to the right of <span class="emphasis"><em>x
      = h</em></span>.
    </p>
<p>
      That is the area shaded in the figure below (Owens 1956).
    </p>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="inlinemediaobject"><img src="../../graphs/owens_integration_area.svg" align="middle"></span>

      </p></blockquote></div>
<p>
      and is also illustrated by a 3D plot.
    </p>
<p>
      <span class="inlinemediaobject"><img src="../../graphs/plot_owens_3d_xyp.png"></span>
    </p>
<p>
      This function is used in the computation of the <a class="link" href="dist_ref/dists/skew_normal_dist.html" title="Skew Normal Distribution">Skew
      Normal Distribution</a>. It is also used in the computation of bivariate
      and multivariate normal distribution probabilities. The return type of this
      function is computed using the <a class="link" href="result_type.html" title="Calculation of the Type of the Result"><span class="emphasis"><em>result
      type calculation rules</em></span></a>: the result is of type <code class="computeroutput"><span class="keyword">double</span></code> when T is an integer type, and type T
      otherwise.
    </p>
<p>
      Owen's original paper (page 1077) provides some additional corner cases.
    </p>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(h, 0) = 0</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(0, a) = ½π arctan(a)</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(h, 1) = ½ G(h) [1 - G(h)]</em></span></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="serif_italic"><span class="emphasis"><em>T(h, ∞) = G(|h|)</em></span></span>
      </p></blockquote></div>
<p>
      where G(h) is the univariate normal with zero mean and unit variance integral
      from -∞ to h.
    </p>
<h5>
<a name="math_toolkit.owens_t.h2"></a>
      <span class="phrase"><a name="math_toolkit.owens_t.accuracy"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.accuracy">Accuracy</a>
    </h5>
<p>
      Over the built-in types and range tested, errors are less than 10 * std::numeric_limits&lt;RealType&gt;::epsilon().
    </p>
<div class="table">
<a name="math_toolkit.owens_t.table_owens_t"></a><p class="title"><b>Table 8.86. Error rates for owens_t</b></p>
<div class="table-contents"><table class="table" summary="Error rates for owens_t">
<colgroup>
<col>
<col>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
            </th>
<th>
              <p>
                GNU C++ version 7.1.0<br> linux<br> double
              </p>
            </th>
<th>
              <p>
                GNU C++ version 7.1.0<br> linux<br> long double
              </p>
            </th>
<th>
              <p>
                Sun compiler version 0x5150<br> Sun Solaris<br> long double
              </p>
            </th>
<th>
              <p>
                Microsoft Visual C++ version 14.1<br> Win32<br> double
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                Owens T (medium small values)
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 0ε (Mean = 0ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.34ε (Mean = 0.944ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.34ε (Mean = 0.911ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 4.37ε (Mean = 0.98ε)</span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                Owens T (large and diverse values)
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 0ε (Mean = 0ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 49ε (Mean = 2.16ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 24.5ε (Mean = 1.39ε)</span>
              </p>
            </td>
<td>
              <p>
                <span class="blue">Max = 3.78ε (Mean = 0.621ε)</span>
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><h5>
<a name="math_toolkit.owens_t.h3"></a>
      <span class="phrase"><a name="math_toolkit.owens_t.testing"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.testing">Testing</a>
    </h5>
<p>
      Test data was generated by Patefield and Tandy algorithms T1 and T4, and also
      the suggested reference routine T7.
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          T1 was rejected if the result was too small compared to <code class="computeroutput"><span class="identifier">atan</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span></code>
          (ie cancellation),
        </li>
<li class="listitem">
          T4 was rejected if there was no convergence,
        </li>
<li class="listitem">
          Both were rejected if they didn't agree.
        </li>
</ul></div>
<p>
      Over the built-in types and range tested, errors are less than 10 std::numeric_limits&lt;RealType&gt;::epsilon().
    </p>
<p>
      However, that there was a whole domain (large <span class="emphasis"><em>h</em></span>, small
      <span class="emphasis"><em>a</em></span>) where it was not possible to generate any reliable
      test values (all the methods got rejected for one reason or another).
    </p>
<p>
      There are also two sets of sanity tests: spot values are computed using <a href="http://www.wolfram.com/products/mathematica/index.html" target="_top">Wolfram Mathematica</a>
      and <a href="http://www.r-project.org/" target="_top">The R Project for Statistical Computing</a>.
    </p>
<h5>
<a name="math_toolkit.owens_t.h4"></a>
      <span class="phrase"><a name="math_toolkit.owens_t.implementation"></a></span><a class="link" href="owens_t.html#math_toolkit.owens_t.implementation">Implementation</a>
    </h5>
<p>
      The function was proposed and evaluated by <a href="http://projecteuclid.org/DPubS?service=UI&amp;version=1.0&amp;verb=Display&amp;handle=euclid.aoms/1177728074" target="_top">Donald.
      B. Owen, Tables for computing bivariate normal probabilities, Ann. Math. Statist.,
      27, 1075-1090 (1956)</a>.
    </p>
<p>
      The algorithms of Patefield, M. and Tandy, D. "Fast and accurate Calculation
      of Owen's T-Function", Journal of Statistical Software, 5 (5), 1 - 25
      (2000) are adapted for C++ with arbitrary RealType.
    </p>
<p>
      The Patefield-Tandy algorithm provides six methods of evaluation (T1 to T6);
      the best method is selected according to the values of <span class="emphasis"><em>a</em></span>
      and <span class="emphasis"><em>h</em></span>. See the original paper and the source in <a href="../../../../../boost/math/special_functions/owens_t.hpp" target="_top">owens_t.hpp</a>
      for details.
    </p>
<p>
      The Patefield-Tandy algorithm is accurate to approximately 20 decimal places,
      so for types with greater precision we use:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          A modified version of T1 which folds the calculation of <span class="emphasis"><em>atan(h)</em></span>
          into the T1 series (to avoid subtracting two values similar in magnitude),
          and then accelerates the resulting alternating series using method 1 from
          H. Cohen, F. Rodriguez Villegas, D. Zagier, "Convergence acceleration
          of alternating series", Bonn, (1991). The result is valid everywhere,
          but doesn't always converge, or may become too divergent in the first few
          terms to sum accurately. This is used for <span class="emphasis"><em>ah &lt; 1</em></span>.
        </li>
<li class="listitem">
          A modified version of T2 which is accelerated in the same manner as T1.
          This is used for <span class="emphasis"><em>h &gt; 1</em></span>.
        </li>
<li class="listitem">
          A version of T4 only when both T1 and T2 have failed to produce an accurate
          answer.
        </li>
<li class="listitem">
          Fallback to the Patefiled Tandy algorithm when all the above methods fail:
          this happens not at all for our test data at 100 decimal digits precision.
          However, there is a difficult area when <span class="emphasis"><em>a</em></span> is very
          close to 1 and the precision increases which may cause this to happen in
          very exceptional circumstances.
        </li>
</ul></div>
<p>
      Using the above algorithm and a 100-decimal digit type, results accurate to
      80 decimal places were obtained in the difficult area where <span class="emphasis"><em>a</em></span>
      is close to 1, and greater than 95 decimal places elsewhere.
    </p>
</div>
<div class="copyright-footer">Copyright © 2006-2021 Nikhar Agrawal, Anton Bikineev, Matthew Borland,
      Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert Holin, Bruno
      Lalande, John Maddock, Evan Miller, Jeremy Murphy, Matthew Pulver, Johan Råde,
      Gautam Sewani, Benjamin Sobotta, Nicholas Thompson, Thijs van den Berg, Daryle
      Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="inv_hyper/atanh.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../special.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="daubechies.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
